<?php

class UploadController extends \AdminController {
    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function upload()
    {
        if (Request::isMethod('post')) {
            $options = array(
                'thumb_max_width'  => Config::get('constants.UPLOAD.THUMBNAIL.MAX_WIDTH'),
                'thumb_max_height' => Config::get('constants.UPLOAD.THUMBNAIL.MAX_HEIGHT'),
                'controlId'        => Config::get('constants.UPLOAD.FOLDER_TMP'),
                'user_dirs'        => true
            );

            $pathDelete = public_path().'/'.Config::get('constants.UPLOAD.FOLDER_NAME').
                '/'.Config::get('constants.UPLOAD.FOLDER_TMP')
                .'/'.session_id();

            if (Utility::deleteDirectory($pathDelete)) {
                new UploadHandler($options);
            }
        }
    }
}
